﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefProdBatchMaterialRecord" :model="stateProdBatchMaterialRecord.vmModel" label-width="100px">
    <div style="margin-bottom:10px;">{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_MaterialCode_FormItem" prop="LinkedVM.MaterialCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_MaterialCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdBatchMaterialRecord_MaterialCode')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.MaterialCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Barcode_FormItem" prop="LinkedVM.Barcode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Barcode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_ProdBatchMaterialRecord_Barcode')}), trigger: 'blur' }]" >
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.Barcode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Wo_FormItem" prop="LinkedVM.Wo" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Wo')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.Wo" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Qty_FormItem" prop="LinkedVM.Qty" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_Qty')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.Qty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_UsedQty_FormItem" prop="LinkedVM.UsedQty" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_UsedQty')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.UsedQty" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineId_FormItem" prop="LinkedVM.LineId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_LineId')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.LineId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineCode_FormItem" prop="LinkedVM.LineCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_LineCode')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.LineCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpId_FormItem" prop="LinkedVM.OpId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_OpId')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.OpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_OpCode_FormItem" prop="LinkedVM.OpCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_OpCode')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.OpCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_FeedingTime_FormItem" prop="LinkedVM.FeedingTime" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_FeedingTime')">
          <el-date-picker v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.FeedingTime" type='date' clearable></el-date-picker>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ScanOpId_FormItem" prop="LinkedVM.ScanOpId" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_ScanOpId')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.ScanOpId" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_ScanOpCode_FormItem" prop="LinkedVM.ScanOpCode" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_ScanOpCode')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.ScanOpCode" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_FeedingBy_FormItem" prop="LinkedVM.FeedingBy" :label="$t('message.autotrans._Model_ProdBatchMaterialRecord_FeedingBy')">
          <el-input v-model="stateProdBatchMaterialRecord.vmModel.LinkedVM.FeedingBy" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitProdBatchMaterialRecord"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseProdBatchMaterialRecord"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProductionManagementProdBatchMaterialRecordBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { prodbatchmaterialrecordApi } from '/@/api/productionmanagement/prodbatchmaterialrecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefProdBatchMaterialRecord = ref();
const stateProdBatchMaterialRecord = reactive({
    vmModel: {
	  LinkedVM:{
        MaterialCode: '',
        Barcode: '',
        Wo: '',
        LineCode: '',
        OpCode: '',
        FeedingTime: undefined,
        ScanOpCode: '',
        FeedingBy: '',
      },
      Ids:[],
      
	},
    
});

// 取消
const onCloseProdBatchMaterialRecord = () => {
    closeDialog();
};

// 提交
const onSubmitProdBatchMaterialRecord = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefProdBatchMaterialRecord.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            prodbatchmaterialrecordApi().batchedit(stateProdBatchMaterialRecord.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};


// 页面加载时
onMounted(() => {
    
    if (ci.attrs["wtmdata"]) {
		stateProdBatchMaterialRecord.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateProdBatchMaterialRecord.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

